package com.epower.dataobject;

import java.util.Collections;
import java.util.Date;
import java.util.List;

import com.epower.base.BaseDO;
import com.epower.bo.epowersentence.EpowerSentenceService;
import com.epower.utils.HttpUtils;
import com.epower.utils.SpringUtils;

public class EpowerWordDO extends BaseDO {

	private static final long serialVersionUID = 1L;

	private Integer id;

	private Integer bookid;

	private String spelling;

	private String phonetics;

	private String meaning;

	private Integer status;

	/**
	 * createtime
	 */
	private Date createtime;

	/**
	 * updatetime
	 */
	private Date updatetime;

	private int level;

	public int getLevel() {
		return level;
	}

	public void setLevel(int level) {
		this.level = level;
	}

	private List<EpowerSentenceDO> sentenceList;

	private static EpowerSentenceService epowerSentenceBO;

	@SuppressWarnings("unchecked")
	public List<EpowerSentenceDO> getSentenceList() {

		if (epowerSentenceBO == null) {
			epowerSentenceBO = (EpowerSentenceService) SpringUtils.getBean("epowerSentenceBO");
		}
		if (spelling == null || spelling.isEmpty()) {
			return Collections.EMPTY_LIST;
		}
		if (sentenceList == null || sentenceList.isEmpty()) {
			sentenceList = epowerSentenceBO.querySentenceBySpelling(spelling);
			if (sentenceList.isEmpty()) {
				sentenceList = HttpUtils.getSentenceListBySpelling(spelling);
				epowerSentenceBO.addEpowerSentence(sentenceList);
			}
		}
		return sentenceList;
	}

	public void setSentenceList(List<EpowerSentenceDO> sentenceList) {
		this.sentenceList = sentenceList;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Integer getBookid() {
		return bookid;
	}

	public void setBookid(Integer bookid) {
		this.bookid = bookid;
	}

	public String getSpelling() {
		return spelling;
	}

	public void setSpelling(String spelling) {
		this.spelling = spelling;
	}

	public String getPhonetics() {
		return phonetics;
	}

	public void setPhonetics(String phonetics) {
		this.phonetics = phonetics;
	}

	public String getMeaning() {
		return meaning;
	}

	public void setMeaning(String meaning) {
		this.meaning = meaning;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public Date getCreatetime() {
		return createtime;
	}

	public void setCreatetime(Date createtime) {
		this.createtime = createtime;
	}

	public Date getUpdatetime() {
		return updatetime;
	}

	public void setUpdatetime(Date updatetime) {
		this.updatetime = updatetime;
	}

	public static void setEpowerSentenceBO(EpowerSentenceService epowerSentenceBO) {
		EpowerWordDO.epowerSentenceBO = epowerSentenceBO;
	}

}
